

def QuestionExtract (QD,PD):
    qid = QD.RandomExtract (PD.u_identity)

    if qid < 0:
        return ['您的另一半还没有设置问题哦！',[],'找不到题目啦！',qid]
    else:
        question_dct = QD.ShowQuestion (PD.u_identity,qid)
        question = question_dct['Question']
        choice = question_dct['Choice']
        type = question_dct['Type']

        return [question,choice,type,qid]


def Judger (QD,PD,answer,qid):
    result = QD.Judger (answer,qid,PD.u_identity)

    if result == 1:
        return '恭喜你，答对啦！'
    else:
        return '答错了，好可惜！'


def AddQuestion (QD,PD,question,choice,qtype,OM):
    for i in range (0,len (choice)):
        if choice[i] == '':
            choice[i] = '对方未设置该选项哦！'
        
    QD.AddQuestion (PD.u_identity,question,choice,qtype)
    OM.SaveObj(QD,'./data/QuestionData.pkl')